'''
Created on Mar 24, 2010

@author: jhlee
'''
import math


class Number3D:
    def __init__(self,x=0,y=0,z=0):
        self.x = x
        self.y = y
        self.z = z
        
    def clone(self):
        return Number3D(self.x, self.y, self.z)
    
    def set(self, x, y, z):
        self.x = x
        self.y = y 
        self.z = z
        
        
    def add(self, rhs):
        self.x = self.x + rhs.x
        self.y = self.y + rhs.y
        self.z = self.z + rhs.z
    def addXYZ(self, x,y,z):
        self.x = self.x + x
        self.y = self.y + y 
        self.z = self.z + z 
        
    def sub(self, rhs):
        self.x = self.x - rhs.x
        self.y = self.y - rhs.y
        self.z = self.z - rhs.z
          
    def copyFrom(self, rhs):
        self.x = rhs.x
        self.y = rhs.y
        self.z = rhs.z
        
    def cross(self, v, out=None):
        w = self        
        out.set((w.y * v.z) - (w.z * v.y), (w.z * v.x) - (w.x * v.z), (w.x * v.y) - (w.y * v.x))
        return out
    
    def scale(self, s):
        self.x = self.x * s 
        self.y = self.y * s
        self.z = self.z * s 
        
    def multiply(self, rhs):
        self.x = self.x * rhs.x
        self.y = self.y * rhs.y
        self.z = self.z * rhs.z
        
    def normalize(self):
        len = self.x*self.x + self.y*self.y + self.z*self.z
        len = math.sqrt(len)
        
        self.x = self.x / len
        self.y = self.y / len
        self.z = self.z / len 
        
        
        
NUMBER_3D_UNIT_SCALE = Number3D(1.0,1.0,1.0)
